﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Demo_SteeringBehaviour
{
    public class Controller
    {
        #region DATA_MEMBERS
        //
        private List<Agent> agents = null;
        private static Controller crtl = null;
        //
        #endregion DATA_MEMBERS

        private Controller() { /*Private Constructor*/ }

        private void Init()
        {
            if(agents == null) { agents = new List<Agent>(); }
        }
        
        
        public static Controller Instance()
        {
            //Singleton Check - lazy instantiation...
            if (null == crtl) { crtl = new Controller();
            }
            return crtl;
        }


        public void AddRock(Rock agent)
        {
            Init(); agents.Add(agent);
        }

        
        public void AddPaper(Paper agent)
        {
            Init(); agents.Add(agent);
        }


        public void AddScissor(Scissor agent)
        {
            Init();  agents.Add(agent);
        }


        public void Update(GameTime gameTime)
        {
            for (int i = 0; i < agents.Count(); ++i)
            {
                agents[i].Update(gameTime, agents);
            }
        }


        public void Draw(SpriteBatch spriteBatch)
        {
            for (int i = 0; i < agents.Count(); ++i)
            {
                agents[i].Draw(spriteBatch);
            }
        }
    }//class
}//namespace
